<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex align-stretch benben-position-layout flex confirmNewPassword_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex align-center justify-between flex-sub confirmNewPassword_fd0_0'>
					<view class='flex align-center confirmNewPassword_fd0_0_c0' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">
						<text class='fu-iconfont2  confirmNewPassword_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view class='flex align-center'>
						<text class='confirmNewPassword_fd0_0_c1_c0'>确认支付密码</text>
					</view>
					<view class='flex align-center confirmNewPassword_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-center benben-flex-layout">
				<text class='confirmNewPassword_fd1_0'>确认新密码</text>
				<text class='confirmNewPassword_fd1_1'>请确认新支付密码，用于支付验证</text>
				<benben-digital-password :box-num='6' mode='password'
					class-name="flex flex align-center justify-center confirmNewPassword_fd1_2" v-model="newPayPwd"
					:init-open.sync="xianshi">
					<template #default="{ content, active, index }">
						<view :key="index" v-if="active"
							class="flex align-center justify-center active-digital-password confirmNewPassword_flex_password_active_fd1_2">
							{{ content }}
						</view>
						<view :key="index" v-else
							class="flex align-center justify-center confirmNewPassword_flex_password_active_fd1_2">
							{{ content }}
						</view>
					</template>
				</benben-digital-password>
				<button class='confirmNewPassword_fd1_3' @tap.stop="checkCodeFunc()">保存</button>
			</view>

			<!---flex布局flex布局结束-->


		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				"newPayPwd": "",
				"xianshi": false,
				"passwordData": {
					"falg": ""
				},
				"password": ""
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let {
				password
			} = options
			if (password !== undefined) this.password = password
			this.whetherToSetFunc()
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//校验验证码
			async checkCodeFunc() {
				if (!validate(this.newPayPwd, 'require')) {
					this.$message.info('请输入支付密码');
					return false;
				}
				if (!validate(this.newPayPwd, 'length', '6')) {
					this.$message.info('请输入6位数字支付密码');
					return false;
				}
				if (!(this.password == this.newPayPwd)) {
					this.$message.info('新密码与确认新密码不一致');
					return false;
				}
				if (this.passwordData.falg == 0) {
					//请求方法
					//数据验证

					let data5f69e0271835d = await this.$api.dbPost(global.apiUrls.post5f69e0271835d, {
						set_pay_password: this.newPayPwd
					});
					if (!data5f69e0271835d) return
					if (data5f69e0271835d.data.code != 1) {
						this.$message.info(data5f69e0271835d.data.msg);
						return
					}
				} else {
					//请求方法
					//数据验证

					let data64f31870bb817 = await this.$api.post(global.apiUrls.post64f31870bb817, {
						pay_password: this.newPayPwd
					});

					if (data64f31870bb817.data.code != 1) {
						this.$message.info(data64f31870bb817.data.msg);
						return
					}
				}
				if (this.passwordData.falg == 0) {
					this.$message.info('设置成功');
					setTimeout(() => {
						this.$urouter.navigateBack(3);
					}, 500)
				} else {
					this.$message.info('修改成功');
					setTimeout(() => {
						this.$urouter.navigateBack(3);
					}, 500)
				}
			},
			//是否设置支付密码
			async whetherToSetFunc() {
				//请求方法
				//数据验证

				let datapasswordData = await this.$api.get(global.apiUrls.post64ed572598eeb, {

				});

				if (datapasswordData.data.code != 1) {
					this.$message.info(datapasswordData.data.msg);
					return
				}
				let infopasswordData = datapasswordData.data;
				this.passwordData = infopasswordData.data

			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #fff;
		background-size: 100% auto;
	}

	.confirmNewPassword_flex_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.confirmNewPassword_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
	}

	.confirmNewPassword_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
	}

	.confirmNewPassword_fd0_0_c0 {
		width: 180rpx;
	}

	.confirmNewPassword_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
	}

	.confirmNewPassword_fd1_3 {
		background: var(--benbenbgColor0);
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor3);
		width: 610rpx;
		height: 88rpx;
		line-height: 88rpx;
		margin: 88rpx 0rpx 0rpx 0rpx;
	}

	.confirmNewPassword_flex_password_active_fd1_2 {
		border: 1px solid rgba(171, 171, 171, 1);
		width: 100rpx;
		height: 100rpx;
	}

	::v-deep .confirmNewPassword_fd1_2 {
		margin: 64rpx 0rpx 24rpx 0rpx;
	}

	.confirmNewPassword_fd1_1 {
		color: #999999;
		font-size: 28rpx;
		font-weight: 400;
		line-height: 40rpx;
	}

	.confirmNewPassword_fd1_0 {
		font-size: 40rpx;
		font-weight: 700;
		color: #333333;
		margin: 175rpx 0rpx 20rpx 0rpx;
		line-height: 56rpx;
	}
</style>